﻿@model BackEnd.Models.MarketingModel
@{
    ViewBag.Title = "Create a marketing";
}

 <h2>Create a marketing</h2>
    @using (Html.BeginForm())
       { 
    @Html.ValidationSummary(true, "Marketing creation was unsuccessful. Please correct the errors and try again.", new { @class="error_box" }) 
           if (ViewData["ErrorMessage"] != null)
       {
    @Html.Label(ViewData["ErrorMessage"].ToString())
    }
    <div>        
            <table>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.Code) 
            </td>
            <td class="editor-field">
                @Html.TextBoxFor(m => m.Code) 
                @Html.ValidationMessageFor(m => m.Code)
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.Title) 
            </td>
            <td class="editor-field">
                @Html.TextBoxFor(m => m.Title) 
                @Html.ValidationMessageFor(m => m.Title)
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.SubscriptionID) 
            </td>
            <td class="editor-field">
                @{var lstSubs = ViewData["ListSubscriptions"] as System.Collections.IEnumerable; }
                @Html.DropDownListFor(m => m.SubscriptionID, new SelectList(lstSubs, "SubscriptionID", "Title"), new { id = "ddlSubscriptions" })
                @Html.ValidationMessageFor(m => m.SubscriptionID)
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.MarketingCatID) 
            </td>
            <td class="editor-field">
                @{var lstMarketingCats = ViewData["ListMarketingCats"] as System.Collections.IEnumerable; }
                @Html.DropDownListFor(m => m.MarketingCatID, new SelectList(lstMarketingCats, "CategoryID", "Code"),"--------", new { id = "ddlMarketingCat" })
                @Html.ValidationMessageFor(m => m.MarketingCatID)
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.FromDate) 
            </td>
            <td class="editor-field">
                @Html.TextBoxFor(m => m.FromDate, new { id = "fdate" })
                @Html.ValidationMessageFor(m => m.FromDate)
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.ToDate) 
            </td>
            <td class="editor-field">
                @Html.TextBoxFor(m => m.ToDate, new { id = "tdate"})
                @Html.ValidationMessageFor(m => m.ToDate)
            </td>
                    </tr>
                <tr>
             <td class="editor-label">
                @Html.LabelFor(m => m.Contents)
            </td>
            <td class="editor-field">
                @Html.TextAreaFor(m => m.Contents, new { id = "txaContents"})
                
            </td>
                    </tr>
                <tr>
            <td class="editor-label">
                @Html.LabelFor(m => m.Discount) 
            </td>
            <td class="editor-field">
                @Html.TextBoxFor(m => m.Discount) 
                @Html.ValidationMessageFor(m => m.Discount)
            </td>
                    </tr>
                <tr>
            <td class="editor-label" id="lblCouponCode">
                @Html.LabelFor(m => m.CouponCode) 
            </td>
            <td class="editor-field" id="txtCouponCode">
                @Html.TextBoxFor(m => m.CouponCode)
                @Html.ValidationMessageFor(m => m.CouponCode)
            </td>
            </tr>
                <tr>
                    <td></td>
                    <td>
            
                <img class="NFButtonLeft NFh" src="/Content/Img/0.png"><input id="submit" class="NFButton NFh" type="submit" value="Create" name="submit"><img class="NFButtonRight NFh" src="/Content/Img/0.png">@Html.ActionLink("Back","Index")
            
                        </td>
                    </tr>
            </table>
        
    </div>
    } 
<script src="~/Scripts/ckeditor/ckeditor.js"></script>
    <script src="~/Scripts/ckeditor/adapters/jquery.js"></script>
    @*@Scripts.Render("~/bundles/ckeditor")*@
    <script type="text/javascript">
        $(function () {
           
            $('#lblCouponCode').hide();
            $('#txtCouponCode').hide();

            $('#ddlMarketingCat').change(function () {

                var cat = $('#ddlMarketingCat').val();
                if (cat == "2") {

                    $('#lblCouponCode').show();
                    $('#txtCouponCode').show();
                }
                else {
                    $('#lblCouponCode').hide();
                    $('#txtCouponCode').hide();
                }


            });
            $('#fdate').datepicker();
            $('#tdate').datepicker();
            //txaContents
            $('#txaContents').ckeditor();

        });
    </script>